package com.bl._03oneway;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

public class Producer {
    public static void main(String[] args) throws Exception {
        // 1 创建生产者对象
        DefaultMQProducer producer = new DefaultMQProducer("oneway_producer_group");
        // 2 设置nameserver地址
        producer.setNamesrvAddr("localhost:9876");
        // 3 启动
        producer.start();
        // 4 创建消息并设置消息
        Message message = new Message("oneway", "hello", "学习学习学习".getBytes(StandardCharsets.UTF_8));
        // 5 发送消息
       producer.sendOneway(message);
        // 关闭
        producer.shutdown();


    }



}
